include("shared.lua")
include("cl_buildingsgui.lua")
include("cl_buildings.lua")
include("cl_ghost.lua")
include("cl_vote.lua")
include("upgradetree/cl_init.lua")

BUILDING.ChosenOption = 1

function BUILDING:Set( opt )

	self.ChosenOption = opt
	
	if self.DEBUG then
		Msg("Setting option: " .. opt .. "\n")
	end

end

function BUILDING:Get()
	return self.ChosenOption
end

function BUILDING:GetModel()
	
	local Id = self:Get()
	local Item = self.List[ Id ]
	
	if Item then
		return Item.model
	end

end

local TextHeight = draw.GetFontHeight("Default")
local TextLenght = surface.GetTextSize("Vote for a commander")
local TextLenght2 = surface.GetTextSize("Press F4 to vote")

function COMMVOTE:DrawRequestVote()

	local TimeLeft = COMMVOTE:TimeLeft()
	
	if TimeLeft < 0 then
		return
	end

	local x,y = 10, 10
	local w,h = TextLenght + 8, TextHeight * 2 + 10

	draw.RoundedBox( 8,x,y,w,h , Color(100,100,100,180) )
	
	surface.SetFont("Default")
	surface.SetTextColor( 255, 255, 255, 255 )
	
	surface.SetTextPos( x + 5, y + 2 )
	surface.DrawText( "Vote for a commander" )
	
	surface.SetTextPos( x + w/2 - TextLenght2/2, y + TextHeight + 4 )
	surface.DrawText( "Press F4 to vote" )
	
	surface.SetDrawColor( 255, 255, 255, 100 )
	surface.SetTexture( 0 )
	surface.DrawPoly( draw.GetCircle( TimeLeft / COMMVOTE.WaitTime, x + w/2, y + h/2, h * 0.35, 16 ) )

end

hook.Add("HUDPaint", "DrawVoteComm",  COMMVOTE.DrawRequestVote )